function read() {
	if($("#1").attr('checked')) {
		$('[name=id754]').attr("disabled",'');
		$('[name=id755]').attr("disabled",'');
		$('[name=id756]').attr("disabled",'');
		$('[name=id757]').attr("disabled",'');
		$('[name=id756]').attr("class",'line-input');
		$('[name=id757]').attr("class",'line-input');
	}else {
		$('[name=id754]').attr("disabled",'true');
		$('[name=id755]').attr("disabled",'true');
		$('[name=id756]').attr("disabled",'true');
		$('[name=id757]').attr("disabled",'true');
		$('[name=id756]').attr("class",'line-read');
		$('[name=id757]').attr("class",'line-read');
	}
}

	var cookie=getCookie("cookie");
	var cannotModify=msg.cannotModify1;
	var noNum=dialingRules.nonumber;
	var existed=msg.idExisted;
	var loopvalue=new Array();
	var linenumber='';var phonenumber='';var tmparray=new Array();
	$.get("/xml?method=gw.config.get&id=4000&id=4020&id=518&cookie="+cookie+"&tmp="+Math.random(),function (data) {
		if($(data).find("rsp").attr("stat")=="ok") {
			var j=0;
			var flag='';
			var flagfxs='';var tmp='';
			$(data).find("item").each(function(){
			if($(this).attr("id")=="518"){
				tmp = $(this).attr("value");
			}else{
			$(this).find('value').each(function () {
				if($(this).text().split("/")[2]!=='') {
					if($(this).text().split("/")[0].indexOf("FXS")) {
						flag='FXS';
					}else if($(this).text().split("/")[0].indexOf("IPEXT")) {
						flagfxs='IPEXT';
					}
					loopvalue[j]=$(this).text();
					j++;
				}
				if($(this).text().split("/")[2]!=='') {
					if(linenumber.indexOf($(this).text().split("/")[2].substr(0,1))<0) {
						linenumber+=decodeURIComponent($(this).text()).split("/")[2].substr(0,1)+",";
					}
				}
				
				var listvalue=$(this).text().split("/");
				tmparray[listvalue[1]]=listvalue[2];
			});
		}
			});
			if(tmp.indexOf("|")>=0){
				var value518=tmp.split("|");
				for(var s=0;s<value518.length;s++){
					var num=value518[s];
					if(tmparray[num]!==''){
						phonenumber+=tmparray[num]+',';
					}
				}
			}else{
				if(tmparray[tmp]!==""){
					phonenumber=tmparray[tmp]+",";
				}
			}
			phonenumber=phonenumber.substr(0,phonenumber.length-1);
			if(!phonenumber){phonenumber='';tmp='';}
			$("[name=operator1]").attr("value",phonenumber);
			$("[name=operator1]").attr("truevalue",tmp);
			
			$("[name=operator1]").blur(function () {
				var name=$("[name=operator1]").attr("name");
				var thisvalue=$("[name=operator1]").val();
				if(thisvalue.indexOf(",")>=0) {
					if(thisvalue=='') {
						$("[name=operator1]").attr("truevalue",'');
					}else {
						var flag='';
						var z=0;
						var this_value='';
						var truevalue='';
						thisvalue=thisvalue.split(",");
						$(thisvalue).each(function () {
							for(var s=0;s<loopvalue.length;s++) {
								if(loopvalue[s].split("/")[2]==thisvalue[z]) {
									this_value+=loopvalue[s].split("/")[2]+",";
									truevalue+=loopvalue[s].split("/")[1]+"|";
									flag='true';
									break;
								}else {
									flag='false';
								}
							}
							z++;
						});
						this_value=this_value.substr(0,this_value.length-1);
						truevalue=truevalue.substr(0,truevalue.length-1);
						$("[name=operator1]").attr("value",this_value);
						$("[name=operator1]").attr("truevalue",truevalue);
						if(flag=="false") {
							//show_message("err",dialingRules.nonumber);
							alert(dialingRules.nonumber);
							$("[name=operator1]").attr("value",'');
							$("[name=operator1]").attr("truevalue",'');
						}
					}
				}else {
					if(thisvalue=='') {
						$("[name=operator1]").attr("truevalue",'');
					}else {
						var flag='';
						for(var s=0;s<loopvalue.length;s++) {
							if(loopvalue[s].split("/")[2]==thisvalue) {
								$("[name=operator1]").attr("value",loopvalue[s].split("/")[2]);
								$("[name=operator1]").attr("truevalue",loopvalue[s].split("/")[1]);
								flag='true';
								break;
							}else {
								flag='false';
							}
						}if(flag=="false") {
							//show_message("err",dialingRules.nonumber);
							alert(dialingRules.nonumber);
							$("[name=operator1]").attr("value",'');
							$("[name=operator1]").attr("truevalue",'');
						}
					}
				}
			});
			var gettexts='&id=771';
			var url='/xml?method=gw.config.get'+gettexts+'&id=740&id=741&line_id=1&id=750&cookie='+cookie+'&tmp='+Math.random();
			$.get(url,function (data) {
				var stat=$(data).find('rsp').attr("value");
				if(stat=="fail") {
					$(data).find('Error').each(function () {
						var code=$(this).attr('code');
						if(code==4) {
							//show_message("err",cannotModify);
							alert(cannotModify);
						}else if(code==5) {
							gotologin();
						}
					});
				}else {
					var value740='';
					var value741='';
					$(data).find('item').each(function () {
						if($(this).attr("id")=="740") {
							if($(this).attr("value").indexOf(".")>=0) {
								value740=$(this).attr("value").split(".")[0];
							}else {
								value740=$(this).attr("value");
							}
						}else if($(this).attr("id")=="741") {
							if($(this).attr("value").indexOf(".")>=0) {
								value741=$(this).attr("value").split(".")[0];
							}else {
								value741=$(this).attr("value");
							}
						}
					});
					var ivrarray740=new Array();
					var ivrarray741=new Array();
					var n=0;
					var m=0;
					$(data).find('item').each(function () {
						if($(this).attr("id")=="771") {
							var ivrs=$(this).attr("value").split("|");
							for(var i=0;i<ivrs.length;i++) {
								if(ivrs[i].indexOf("user")>=0) {
									ivrarray740[n]=ivrs[i].split(".")[0];
									n++;
									ivrarray741[m]=ivrs[i].split(".")[0];
									m++;
								}else if(ivrs[i].indexOf("welcome")>=0) {
									ivrarray740[n]=ivrs[i].split(".")[0];
									n++;
								}else if(ivrs[i].indexOf("offhour")>=0) {
									ivrarray741[m]=ivrs[i].split(".")[0];
									m++;
								}
							}
						}else if($(this).attr("id")=="750") {
							$("[name=id750]").attr("value",$(this).attr("value").split("/")[0]);
						}
					});
					ivrarray740=unique(ivrarray740);
					ivrarray741=unique(ivrarray741);
					var optionstr740='';
					var optionstr741='';
					for(var i=0;i<ivrarray740.length;i++) {
						if(ivrarray740[i]==value740) {
							optionstr740+='<option selected>'+ivrarray740[i]+'</option>';
						}else {
							optionstr740+='<option>'+ivrarray740[i]+'</option>';
						}
					}for(var j=0;j<ivrarray741.length;j++) {
						if(ivrarray741[j]==value741) {
							optionstr741+='<option selected>'+ivrarray741[j]+'</option>';
						}else {
							optionstr741+='<option>'+ivrarray741[j]+'</option>';
						}
					}$(optionstr740).appendTo("select[name=id740]");
					$(optionstr741).appendTo("select[name=id741]");
					var gettext='';
					var nonames=new Array('button','tts','submit','filename','upload','reset','operator1','operator2','operator3','operator4','operator5','ok','reset','checkline',"autocall","id750","id740","id741");
					gettext += getSendText(nonames);
					sendinfo(gettext,nonames);
					setTimeout("read()",100);
				}
			});
			var nonames=new Array('button','tts','submit','filename','upload','reset','operator1','operator2','operator3','operator4','operator5','ok','reset','checkline',"autocall","id750");
			$("[name=submit]").click(function () {
				$(".errormsg").html('');
				var settext='';
				$(":input").each(function () {
					if(checkname(nonames,$(this).attr('name'))) {
						if($(this).attr("type")=="radio") {
							if($(this).attr('checked')) {
								settext+="&"+$(this).attr('name')+"="+$.trim($(this).val());
							}
						}else {
							settext+="&"+$(this).attr('name')+"="+$.trim($(this).val());
						}
					}
				});
				var opvalue=$("[name=operator1]").attr("truevalue");
				if(!opvalue) {
					opvalue='';
				}settext+='&id518='+opvalue;
				settext+='&line_id=1&id750='+$("[name=id750]").val()+"/OPER";
				settext=settext.replace(/\#/g,"%23");
				submitform(modules["set_data"],settext);
			});
			var url='/xml?method=gw.config.get&line_id=2&id=750&line_id=3&id=750&line_id=4&id=750&line_id=5&id=750&line_id=6&id=750&line_id=7&id=750&line_id=8&id=750&cookie='+cookie+'&tmp='+Math.random();
			$.get(url,function (data) {
				var stat=$(data).find('rsp').attr("value");
				if(stat=="fail") {
					$(data).find('Error').each(function () {
						var code=$(this).attr('code');
						if(code==4) {
							//show_message("err",cannotModify);
							alert(cannotModify);
						}else if(code==5) {
							gotologin();
						}
					});
				}else {
					var number='';
					var prefixs='';
					$(data).find('item').each(function () {
						if($(this).attr("id")=="750") {
							var tmpvalue=decodeURIComponent($(this).attr("value"));
							var tmp=tmpvalue.split("/")[0];
							prefixs+=tmp.substr(0,1)+',';
						}
					});
					$("[name=id750]").blur(function () {
						var thisvalue=$(this).attr("value");
						var this_id=$(this).attr("id");
						var thisid=this_id.split("input")[1];
						var blurvalue=thisvalue.substr(0,1)+",";
						if(thisvalue!=="") {
							if(linenumber.indexOf(blurvalue)>=0||prefixs.indexOf(blurvalue)>=0) {
								//show_message("err",existed);
								alert(existed);
								$("[name=id750]").attr("value","");
							}
						}
					});
				}
			});
		}
	});
